/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using System.Collections.Generic;
using NetProtocol.POD;
using NetProtocol.Enum;
using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;
using IQIGame.Onigao.Framework;
using Cysharp.Threading.Tasks;
using System;
using static IQIGame.Onigao.Game.MessageWrapper;

namespace NetProtocol.Client {
	/// <summary>
	/// 运营活动模块
	/// module : operationsEvent
	/// </summary>
	public interface CNetOperationsEvent : INetClientModule {
		
		public ISession GetSession();
	
		Dictionary<int, INetClientModule.Package2MessageWrapper> INetClientModule.GetModuleFunction()
        {
            MessageFunction notifyAllEventStatus_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyAllEventStatusData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.operationsEvent_notifyAllEventStatus, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyAllEventStatus(session, _wrapper.message.list);
                MessageWrapperPool<NotifyAllEventStatusData>.Put(_wrapper);
            };
            MessageFunction notifyOperationsEventData_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyOperationsEventDataData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.operationsEvent_notifyOperationsEventData, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyOperationsEventData(session, _wrapper.message.pod);
                MessageWrapperPool<NotifyOperationsEventDataData>.Put(_wrapper);
            };
        
            Dictionary<int, INetClientModule.Package2MessageWrapper> retDic = new()
            {
                {NetMessageId.operationsEvent_notifyAllEventStatus, (session, package) => {
                	var result = MessageWrapperPool<NotifyAllEventStatusData>.Get();
                	result.Init(session, notifyAllEventStatus_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.operationsEvent_notifyOperationsEventData, (session, package) => {
                	var result = MessageWrapperPool<NotifyOperationsEventDataData>.Get();
                	result.Init(session, notifyOperationsEventData_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
            };
            return retDic;
        }
#region Client-side Interface
		/// <summary>
        /// 
        /// </summary>
		protected void SC_notifyAllEventStatus(ISession session, List<OperationEventPOD> list);
		/// <summary>
        /// 
        /// </summary>
		protected void SC_notifyOperationsEventData(ISession session, OperationEventDataPOD pod);
#endregion
#region Server-side Interface
#endregion
#region Messages
        public struct NotifyAllEventStatusData : IReceiveMessage {
	        public List<OperationEventPOD> list;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                list = _in.HasRemaining() ? _in.Read_list_pod<OperationEventPOD>(OperationEventPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.operationsEvent_notifyAllEventStatus;}
            
            public override string ToString()
            {
                return "OperationsEvent.notifyAllEventStatus"+ ", list="+ list.ToString<OperationEventPOD>();
            }
        }
        public struct NotifyOperationsEventDataData : IReceiveMessage {
	        public OperationEventDataPOD pod;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                pod = _in.HasRemaining() ? _in.Read_pod<OperationEventDataPOD>(OperationEventDataPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.operationsEvent_notifyOperationsEventData;}
            
            public override string ToString()
            {
                return "OperationsEvent.notifyOperationsEventData"+ ", pod="+ pod;
            }
        }
    }
#endregion
}